package com.jinglin.admin.controller;


import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.jinglin.controller.ABaseController;
import com.jinglin.entity.po.UserInfo;
import com.jinglin.entity.query.UserInfoQuery;
import com.jinglin.entity.vo.PaginationResultVO;
import com.jinglin.entity.vo.ResponseVO;
import com.jinglin.service.UserInfoService;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
@RequestMapping("/user")
@Validated
public class UserController extends ABaseController {
    @Resource
    private UserInfoService userInfoService;

    @RequestMapping("/loadUser")
    public ResponseVO loadUser(Integer pageSize,Integer pageNo) {

        PaginationResultVO resultVO = userInfoService.loadUser(pageSize,pageNo);
        return getSuccessResponseVO(resultVO);
    }

    @RequestMapping("/changeStatus")
    public ResponseVO changeStatus(String userId, Integer status) {
        LambdaUpdateWrapper<UserInfo> wrapper = new LambdaUpdateWrapper<>();
        wrapper.eq(UserInfo::getUserId,userId);
        wrapper.set(UserInfo::getStatus,status);
        userInfoService.update(wrapper);
        return getSuccessResponseVO(null);
    }
}
